//
//  DPWalletWithDrawResultViewController.swift
//  DoctorEPlus
//
//  Created by 王林波 on 2021/3/8.
//

import UIKit

class DPWalletWithDrawResultViewController: BHBaseViewController {

    lazy var tableView: UITableView = {
        let view = UITableView.buildTableView(style: .plain)
        
        view.frame = CGRect(x: 0, y: UIScreen.begainY, width: UIScreen.width, height: UIScreen.showHeight)
        view.register(UINib.init(nibName: "DPWalletInfoShowCell", bundle: nil), forCellReuseIdentifier: "DPWalletInfoShowCell")
        view.register(UINib.init(nibName: "DPWalletWithDrawWayCell", bundle: nil), forCellReuseIdentifier: "DPWalletWithDrawWayCell")
       
        view.delegate = self
        view.dataSource = self
        return view
    }()
    
    var money: String = ""
    var account: String = ""
    
    
    
    override func viewDidLoad() {
        super.viewDidLoad()

        self.bh_navigationBar.title_label.text = "提现申请"
        self.view.addSubview(self.tableView)
        
        self.bh_navigationBar.rightBtn.isHidden = false
        
        var tempArray = self.navigationController!.viewControllers
        for (index, item) in tempArray.enumerated() {
            if item is DPMeWalletWithDrawViewController {
                tempArray.remove(at: index)
                break
            }
        }
        self.navigationController?.viewControllers = tempArray
    }
    
    override func rightBtnAction() {
        self.navigationController?.popToRootViewController(animated: true)
    }
}


extension DPWalletWithDrawResultViewController: UITableViewDelegate,UITableViewDataSource {
    func numberOfSections(in tableView: UITableView) -> Int {
        return 1
    }
    
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return 3
    }
    
    func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
        if indexPath.row == 0 {
            return DPWalletInfoShowCell.cellHeight
        }
        else {
            return DPWalletWithDrawWayCell.cellHeight
        }
    }
    
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        if indexPath.row == 0 {
            let cell = tableView.dequeueReusableCell(withIdentifier: "DPWalletInfoShowCell", for: indexPath) as! DPWalletInfoShowCell
            return cell
        }else {
            let cell = tableView.dequeueReusableCell(withIdentifier: "DPWalletWithDrawWayCell", for: indexPath) as! DPWalletWithDrawWayCell
            if indexPath.row == 1 {
                cell.name_label.text = "提现金额"
                cell.account_label.text = "¥ \(self.money)"
            }else {
                cell.name_label.text = "到账方式"
                cell.account_label.text = self.account
            }
            return cell
        }
    }
}
